<template>
  <div>
      <h3 class="title">搜索</h3>
      <!-- <button @click="goBack">自己的返回</button> -->
      <go-back></go-back>
      
      <!-- 绑定到页面 -->
      <input type="text" placeholder="请输入关键词" v-model="kw" autofocus @keydown.enter="enter">

      <hr>
      <!-- 5.封装组件 -->
      <v-list :list="results"></v-list>
  </div>
</template>

<script>
import {reqSearch} from "../../http/http"
export default {
    data() {
    return {
     //初始化数据
     kw:"",//关键词
     results:[]//搜索结果
    };
  },
  methods:{
        goBack(){
            this.$router.go(-1)
        },
        enter(){
          //封装请求
          reqSearch({
            keywords:this.kw,
          }).then((res)=>{
            // console.log(res);
            this.results=res.data.list?res.data.list:[]
          });
        },
    },
}
</script>

<style>
.item {
  padding: 0.2rem;
  margin: 0.2rem;
  border: 0.01rem solid #ccc;
}
</style>